{% comment %}
<!--
  Copyright (C) 2008 ZHENG Zhong <heavyzheng nospam-at gmail D0T com>
  - http://heavyz.blogspot.com/
  - http://buggarden.blogspot.com/

  This template displays a reply to a thread. It requires that the following variables be set:
  - user   : (optional) the current user.
  - info   : (optional) the info message to display.
  - error  : (optional) the error message to display.
  - thread : the thread which is replied.
  - reply  : the reply to display.
  
  The reply is displayed inside a div element with the ID "#reply_{{ reply.key.id }}".

  Created on 2008-05-23.
  $Id: reply.html 252 2008-10-28 11:06:08Z heavyzheng $
-->
{% endcomment %}


<div id="reply_{{ reply.key.id }}" class="post">

  {% if error %}
    <div class="error message">
      {{ error }}
      <a href="javascript:void(0);" onclick="closeMessage();">[close]</a>
    </div><!--/.error-->
  {% endif %}
  
  {% if info %}
    <div class="info message">
      {{ info }}
      <a href="javascript:void(0);" onclick="closeMessage();">[close]</a>
    </div><!--/.info-->
  {% endif %}
  
  
  {% if reply %}
  
    {#--------------------------------------------------------------------------------------------#}
    {# Reply title                                                                                #}
    {#--------------------------------------------------------------------------------------------#}
    
    {% if reply.title %}
      <div class="reply-title">
        {{ reply.title }}
      </div><!--/.reply-title-->
    {% endif %}
    
    {#--------------------------------------------------------------------------------------------#}
    {# Reply header                                                                               #}
    {#--------------------------------------------------------------------------------------------#}
    
    <div class="post-header">
      <a href="#TODO"><b>{{ reply.author.nickname }}</b></a>
      replied at {{ reply.post_date|date:"Y-m-d h:i:s A" }}:
    </div><!--/.post-header-->
    
    {#--------------------------------------------------------------------------------------------#}
    {# Reply content                                                                              #}
    {#--------------------------------------------------------------------------------------------#}
    
    <div class="post-content">
      {{ reply.content|escape|linebreaks }}
    </div><!--/.post-content-->
    
    {#--------------------------------------------------------------------------------------------#}
    {# Reply attachment                                                                           #}
    {#--------------------------------------------------------------------------------------------#}
    
    <div class="post-attachment">
    
      {% if reply.attachment %}
      
        <img src="/static/forum/images/attachment_icon.png" alt="Attachment"/>
        Attachment:
        <a href="/forum/attachment/{{ reply.attachment.key.id }}/">
          {{ reply.attachment.file_name }}
        </a>
        (mime-type: {{ reply.attachment.mime_type }}; size: {{ reply.attachment.size }})
        
        {% if reply.attachment.is_image %}
          <div>
            <img class="post-attachment-image"
                 src="/forum/attachment/{{ reply.attachment.key.id }}/"
                 alt="Attachment: {{ reply.attachment.file_name }}" />
          </div>
        {% endif %}
      
      {% endif %}{# reply.attachment #}
    
    </div><!--/.post-attachment-->
    
    {#--------------------------------------------------------------------------------------------#}
    {# Reply information                                                                          #}
    {#--------------------------------------------------------------------------------------------#}
    
    <div class="post-info">
      {% if reply.edit_date %}
        <img src="/static/forum/images/edit_icon.png" alt="Edited"/>
        This reply was edited by the author at {{ reply.edit_date|date:"Y-m-d h:i:s A" }}.
      {% endif %}
    </div><!--/.post-info-->
    
    {#--------------------------------------------------------------------------------------------#}
    {# Toggles                                                                                    #}
    {#--------------------------------------------------------------------------------------------#}
    
    <div class="form-toggles">
    
      {% if reply.is_current_user_author %}
        <a href="javascript:void(0);" onclick="showEditForm('#reply_{{ reply.key.id }}');">
          <img src="/static/forum/images/edit_icon.png" alt="Edit"/>
          Edit
        </a>
      {% endif %}
      
      {% if reply.is_current_user_author or thread.board.is_current_user_admin %}
        <a href="javascript:void(0);" onclick="showDeleteForm('#reply_{{ reply.key.id }}');">
          <img src="/static/forum/images/delete_icon.png" alt="Delete"/>
          Delete
        </a>
      {% endif %}
    
    </div><!--/.form-toggles-->
    
    {#--------------------------------------------------------------------------------------------#}
    {# Edit reply                                                                                 #}
    {#--------------------------------------------------------------------------------------------#}
    
    {% if reply.is_current_user_author %}
      <form class="edit-form form hidden"
            action="/forum/reply/{{ reply.key.id }}/edit/"
            method="POST"
            enctype="multipart/form-data">
        <p>
          <b>Title:</b><br/>
          <input name="title" type="text" size="80" value="{{ reply.title|default:""|escape }}"/>
        </p>
        <p>
          <b>Content:</b><br/>
          <textarea name="content" rows="10" cols="100">{{ reply.content|escape }}</textarea>
        </p>
        <p>
          <input type="button" value="Submit" onclick="submitEditForm('#reply_{{ reply.key.id }}');"/>
          <input type="button" value="Cancel" onclick="cancelAction('#reply_{{ reply.key.id }}');"/>
        </p>
      </form><!--/.edit-form-->
    {% endif %}
    
    {#--------------------------------------------------------------------------------------------#}
    {# Delete reply                                                                               #}
    {#--------------------------------------------------------------------------------------------#}
    
    {% if reply.is_current_user_author or thread.board.is_current_user_manager %}
      <form class="delete-form form hidden"
            action="/forum/reply/{{ reply.key.id }}/delete/"
            method="POST">
        <p>
          Are you sure you want to delete this reply permanently?
        </p>
        <p>
          <input type="button" value="Yes, I am sure!" onclick="submitDeleteForm('#reply_{{ reply.key.id }}');"/>
          <input type="button" value="No, keep it." onclick="cancelAction('#reply_{{ reply.key.id }}');"/>
        </p>
      </form><!--/.delete-form-->
    {% endif %}
    
    {#--------------------------------------------------------------------------------------------#}
    {# Submitting...                                                                              #}
    {#--------------------------------------------------------------------------------------------#}
    
    <div class="submitting hidden">
      <img src="/static/forum/images/waiting.gif" alt="Submitting"/>
      Submitting your request... Please wait...
    </div><!--/.submitting-->
  
  {% endif %}{# reply #}


</div><!--/#reply_{{ reply.key.id }}-->




